package payment.impl;

import payment.constant.Constants;
import payment.resp.ConsultResult;
import payment.service.PaymentRemoteService;

public class PaymentRemoteServiceImpl implements PaymentRemoteService {

    public static final String SUCCESS = "200";

    public static final String SERVER_ERROR = "501";


    @Override
    public ConsultResult isEnabled(String paymentType) {
        try {
            Thread.sleep(1000 * 3);
            switch (paymentType) {
                case Constants.BALANCE:
                case Constants.VOUCHERS:
                case Constants.RED_ENVELOPE:
                case Constants.COUPONS:
                case Constants.OTHER:
                    return new ConsultResult(true, SUCCESS);
                default:
                    return new ConsultResult(false, SUCCESS);
            }
        } catch (InterruptedException e) {
            return new ConsultResult(false, SERVER_ERROR);
        }

    }
}